package com.jiazhong.cookie;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Auther:shuXin
 */
@WebServlet("/servletA")
public class ServletA extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Cookie username = new Cookie("username", "zhangsan");
        //设置Cookie的存放时间
        //username.setMaxAge(60);
        //设置Cookie的请求的路径
        username.setPath("/conversation_test_war/servletB");
        Cookie password = new Cookie("password", "111111");

        resp.addCookie(username);
        resp.addCookie(password);

    }
}
